# Create your views here.
"""Django view classes for a simple Blog site

   This example shows several simple views that retrieve
   the appropriate objects, populate a template context
   and then render the template.
"""
from django.shortcuts import render_to_response, get_object_or_404

from django.http import HttpResponseRedirect
from datetime import datetime

from sr.models import *

def entry(request):
    #"""Generate the context for the main summary page"""
    latest_project = Project.objects.all()
    #.order_by('-title')[:2]
    return render_to_response('templates/entry.html', 
                              {'latest_project_list': latest_project})

def addEntry(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    return render_to_response('templates/addEntry.html', {'project': project}) 

def postEntry(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    #e = Entry()
    #e.status = 'On track'
    #e.content = request.POST['content']
    #e.save()
    
    #return HttpResponseRedirect('templates/entry/addEntry/%s' % e.id)
#    return HttpResponseRedirect('/entry/addEntry/{project_id}/' )  
    #return HttpResponseRedirect('/')
#, context_instance = RequestContext(request) )  
  
  #CSRF failure: reason=CSRF token missing or incorrect.
  
    #return render_to_response('templates/entry.html', {'project': project}) 
    entry(request)
